package com.ruoyi.contract.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.contract.mapper.ContractPartyMapper;
import com.ruoyi.contract.domain.ContractParty;
import com.ruoyi.contract.service.IContractPartyService;

/**
 * 签约方Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@Service
public class ContractPartyServiceImpl implements IContractPartyService 
{
    @Autowired
    private ContractPartyMapper contractPartyMapper;

    /**
     * 查询签约方
     * 
     * @param contractPartyId 签约方主键
     * @return 签约方
     */
    @Override
    public ContractParty selectContractPartyByContractPartyId(Long contractPartyId)
    {
        return contractPartyMapper.selectContractPartyByContractPartyId(contractPartyId);
    }

    /**
     * 查询签约方列表
     * 
     * @param contractParty 签约方
     * @return 签约方
     */
    @Override
    public List<ContractParty> selectContractPartyList(ContractParty contractParty)
    {
        return contractPartyMapper.selectContractPartyList(contractParty);
    }

    /**
     * 新增签约方
     * 
     * @param contractParty 签约方
     * @return 结果
     */
    @Override
    public AjaxResult insertContractParty(ContractParty contractParty)
    {
        //根据提交信息查询->判断签约方信息是否存在
        ContractParty contractParty1 = contractPartyMapper.selectContractPartyInfo(contractParty);
        if (contractParty1 != null){
            return AjaxResult.error("签约方信息已存在，请勿重复添加");
        }
        contractPartyMapper.insertContractParty(contractParty);
        return AjaxResult.success("新增成功");
    }

    /**
     * 修改签约方
     * 
     * @param contractParty 签约方
     * @return 结果
     */
    @Override
    public int updateContractParty(ContractParty contractParty)
    {
        return contractPartyMapper.updateContractParty(contractParty);
    }

    /**
     * 批量删除签约方
     * 
     * @param contractPartyIds 需要删除的签约方主键
     * @return 结果
     */
    @Override
    public int deleteContractPartyByContractPartyIds(Long[] contractPartyIds)
    {
        return contractPartyMapper.deleteContractPartyByContractPartyIds(contractPartyIds);
    }

    /**
     * 删除签约方信息
     * 
     * @param contractPartyId 签约方主键
     * @return 结果
     */
    @Override
    public int deleteContractPartyByContractPartyId(Long contractPartyId)
    {
        return contractPartyMapper.deleteContractPartyByContractPartyId(contractPartyId);
    }
}
